<%@page import="com.zsgeek.util.PageHelper"%>
<%@ page language="java" contentType="text/html; charset=UTF-8"
	pageEncoding="UTF-8"%>
	
<%
	String action = request.getParameter("action");
	PageHelper pageHelper = (PageHelper) request
			.getAttribute("pageHelper");
	if (pageHelper != null) {
		int pageCount = pageHelper.getPageCount();
		int totalCount = pageHelper.getTotalCount();
		int currentPage = pageHelper.getCurrentPage();
		String pageIndex = request.getParameter("pg");
		int currentIndex = 1;
		if (pageIndex != null) {
			currentIndex = Integer.parseInt(pageIndex);
		}

		if (pageCount > 0) {
%>
<div class="page-box">
	<span style="display:inline-block;float:left;border:none;">
		共<i style="color: #056dae;"><%=totalCount %></i>条记录，当前显示第&nbsp;
		<i style="color: #056dae;"><%=currentPage %>&nbsp;</i>页
	</span>
	<a href="<%=action%>&pg=1">首页</span>
	</a>
	<a href="<%=action%>&pg=<%=(currentIndex - 1) > 0 ? (currentIndex - 1) : 1%>"
		class="disable" id="firstpage">上一页</a>
	<%
		Integer start_num = 0;
				Integer end_num = pageCount;
				if (pageCount > 10) {
					start_num = currentIndex - 1;
					end_num = currentIndex + 10;
					if (end_num > pageCount) {
						end_num = pageCount;
					}
					if (pageCount == currentIndex
							|| (pageCount - currentIndex) < 10) {
						start_num = pageCount - 10;
					}

				} else if (pageCount == currentIndex || pageCount <= 10) {
					start_num = 0;
					end_num = pageCount;
				}
				for (int i = start_num; i < end_num; i++) {
	%>
	<a class="<%=(currentIndex == (i + 1)) ? "current" : ""%>"
		href="<%=action%>&pg=<%=i + 1%>"><%=i + 1%></a>

	<%
		}
	%>
	<a
		href="<%=action%>&pg=<%=(currentIndex + 1) > pageCount ? pageCount
							: (currentIndex + 1)%>"
		id="lastpage">下一页</a>
	<a href="<%=action%>&pg=<%=pageCount%>" aria-label="Next">最后一页</a>

</div>
<%
	}
	}
%>

